package com.etc.controller;

import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.etc.entity.Registration;
import com.etc.service.RegistrationService;

@Controller
public class RegistrationController {
	@Resource
	private RegistrationService registrationService;
	
	/**
	 * 查询所有挂号
	 * @return
	 */
	@RequestMapping(value="registration")
	public String selectRegistration(Model model,HttpServletRequest request) {	
		List<Registration> registration = registrationService.selectRegistration();
		model.addAttribute("list", registration);
		request.getSession().setAttribute("registration",registration );
		
		return "forward:/back/visit-management.jsp";
	}
	
	/**
	 * ajax请求   
	 * 增加预约
	 * @param record 预约对象
	 * @return
	 */
	@RequestMapping(value="addRegistration",method=RequestMethod.POST)
	@ResponseBody
	public int addRegistration(@RequestBody Registration record) {		
		return registrationService.insert(record);
		
	}

	
}
